import { Descriptions} from "antd";
import React, {useEffect, useState} from "react";
import {getFetch} from "@/app/lib/HttpProtocol";
import {User} from "@/app/lib/user";

const apis={
  currentUserApi:'/auth/currentUser'
}
export default function UserInfo(){
  const [user,setUser] = useState<User>({})
  useEffect(() =>{
    getFetch(apis.currentUserApi,null).then(data => {
      // @ts-ignore
      setUser(data);
    })
  },[])
  return (
    <>
    <Descriptions title={(<>用户信息</>)} column={2}>
      <Descriptions.Item label="用户名" span={1}>{user.username}</Descriptions.Item>
      <Descriptions.Item label="昵称" span={1}>{user.nickname}</Descriptions.Item>
      <Descriptions.Item label="手机号" span={1}>{user.mobile}</Descriptions.Item>
      <Descriptions.Item label="邮箱" span={1}>{user.email}</Descriptions.Item>
      <Descriptions.Item label="注册时间" span={2}>{user.addTime}</Descriptions.Item>
    </Descriptions>
    </>
  );
}